package kevin.framework.basic.common.utils;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @Description: 参数URLDecode过滤器
 * @author Yohann.lu
 * @date 2016年9月21日 下午1:50:21
 * @version v1.0.0
 *
 */
public class ParamFilter implements Filter {

	@Override
	public void init(FilterConfig filterConfig) throws ServletException {

	}

	@Override
	public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
			throws IOException, ServletException {
		Map<String, String[]> m = new HashMap<String, String[]>(request.getParameterMap());
		request = new ParameterRequestWrapper((HttpServletRequest) request, m);
		chain.doFilter(request, response);
	}

	@Override
	public void destroy() {

	}

}
